package com.icinfo.cloud.provider.punish.config.vo;

import com.icinfo.cloud.provider.punish.config.enums.DiscretionRuleTypeEnum;
import com.icinfo.cloud.provider.punish.config.model.ConfigOrgRegulatoryDiscretionRuleHis;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Objects;

/**
 *
 * @author HKxxx
 * @date 2024/2/7 14:38
 */
@Data
public class DiscretionHisVo {

    /**
     * 历史id
     */
    private String ruleHisId;

    /**
     * 违法情形
     */
    private String illegalSituation;

    /**
     * 违法情形
     */
    private DiscretionRuleTypeEnum ruleType;

    /**
     * 金额下限
     */
    private BigDecimal lowerLimitAmount;

    /**
     * 金额上限
     */
    private BigDecimal upperLimitAmount;

    /**
     * 固定金额
     */
    private BigDecimal fixAmount;


    public static DiscretionHisVo convertDiscretionHisVo(ConfigOrgRegulatoryDiscretionRuleHis his){
        DiscretionHisVo vo = new DiscretionHisVo();
        if (Objects.isNull(his)){
            return vo;
        }
        vo.setRuleHisId(his.getRuleHisId());
        vo.setIllegalSituation(his.getRuleName());
        vo.setRuleType(DiscretionRuleTypeEnum.getByCode(his.getRuleType()));
        vo.setLowerLimitAmount(his.getLowerLimitAmount());
        vo.setUpperLimitAmount(his.getUpperLimitAmount());
        vo.setFixAmount(his.getFixAmount());
        return vo;
    }

}
